package com.example.javafx;

import com.example.javafx.bilibilidownload.util.CacheUtil;
import com.example.javafx.bilibilidownload.util.SettingsManager;
import com.example.javafx.controller.MainController;
import com.example.javafx.controller.SettingController;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;

public class JavaFxApplication extends Application {

    private static final Logger log = LogManager.getLogger(JavaFxApplication.class);

    @Override
    public void start(Stage primaryStage) throws InterruptedException, IOException {

        log.info("start");

/*        stage.setTitle("Centered Stage Example");
        StackPane root = new StackPane();
        root.getChildren().add(new Label("Hello, JavaFX!"));
        Button button = new Button("test");
        button.setCursor(Cursor.WAIT);
        button.setOnAction(event -> {
            getHostServices().showDocument("https://www.baidu.com");
        });

        Group group = new Group(root);
        group.getChildren().add(button);
        group.setAutoSizeChildren(true);

        Scene scene = new Scene(group, 300, 200);
        stage.setScene(scene);
        stage.initStyle(StageStyle.UNIFIED);
        // 设置居中
        stage.centerOnScreen();
        stage.show();
        Platform.setImplicitExit(false);
        Platform.runLater(()->{
            try {
                Thread.sleep(1000);
                System.out.println(getHostServices().getCodeBase());
                System.out.println(getHostServices().getDocumentBase());
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
//            Platform.exit();
        });*/


/*        AnchorPane anchorPane = new AnchorPane();

        Button button = new Button("Click Me");
        AnchorPane.setTopAnchor(button, 30.0);   // 距离顶部 10 像素
        AnchorPane.setLeftAnchor(button, 20.0);  // 距离左侧 20 像素

        anchorPane.getChildren().add(button);
        Scene scene = new Scene(anchorPane, 300, 200);*/

/*        Text text1 = new Text("Hello ");
        text1.setFont(Font.font("Verdana", 20));

        Text text2 = new Text("World!");
        text2.setFill(Color.BLUE);
        text2.setFont(Font.font("Arial", 25));

        TextFlow textFlow = new TextFlow(text1, text2);
        Scene scene = new Scene(textFlow, 300, 200);*/


        Parent load = CacheUtil.getFxmlPane(MainController.class, "/fxml/main.fxml");
        Scene scene = new Scene(load);
        primaryStage.setScene(scene);
        primaryStage.setTitle("BiliDownload");
        primaryStage.show();
    }


    public static void main(String[] args) {
        System.setProperty("logpath", "/Users/bang/Downloads");
        launch();
    }
}